Core
Pacotes principais do mamba com alguns códigos essenciais e compartilhados.
Extend
Estenda um driver com o driver base.
import extendDriver from '@mamba/core/index.js';
import wrappers from './wrappers.js';
export default extendDriver(driverTarget, wrappers);
Currency
Fornece constante da moeda no POS.
Limite máximo
import { CURRENCY } from '@mamba/core';
CURRENCY.LIMIT;
Keymap
Fornece os mapas-chave e nomes-chave específicos do POS.
KEY_NAMES
import { KEYBOARD } from '@mamba/core';
const { KEY_NAMES, KEY_NAMES_LIST } = KEYBOARD;
KEY_NAMES.ENTER;
KEY_NAMES_LIST;
Values:
{
CLOSE: 'close',
BACK: 'back',
ENTER: 'enter',
HELP: 'help',
SHORTCUTS: 'shortcuts',
SPACE: 'space',
F24: 'F24',
F23: 'F23',
KEY_0: '0',
KEY_1: '1',
KEY_2: '2',
KEY_3: '3',
KEY_4: '4',
KEY_5: '5',
KEY_6: '6',
KEY_7: '7',
KEY_8: '8',
KEY_9: '9',
KEYUP: 'keyup',
ARROW_UP: 'keyup',
KEYDOWN: 'keydown',
ARROW_DOWN: 'keydown',
}
KEY_CODES
import { KEYBOARD } from '@mamba/core';
const { KEY_CODES, KEY_CODES_LIST } = KEYBOARD;
KEY_CODES.ENTER;
KEY_CODES_LIST;
Values:
{
BACK: 8,
ENTER: 13,
SHORTCUTS: 16,
HELP: 17,
CLOSE: 27,
SPACE: 32,
ARROW_UP: 38,
ARROW_DOWN: 40,
KEY_0: 48,
KEY_1: 49,
KEY_2: 50,
KEY_3: 51,
KEY_4: 52,
KEY_5: 53,
KEY_6: 54,
KEY_7: 55,
KEY_8: 56,
KEY_9: 57,
F23: 134,
F24: 135,
KEYUP: 38,
KEYDOWN: 40,
}
KEYMAP
Códigos de chave mapeados para nomes de chave
import { KEYBOARD } from '@mamba/core';
const { KEY_MAP, KEY_NAMES, KEY_1 } = KEYBOARD;
KEY_MAP.13;
KEY_MAP[KEY_NAMES.ENTER];
KEY_MAP[KEY_1];
Values:
{
"8": "back",
"13": "enter",
"16": "shortcuts",
"17": "help",
"27": "close",
"32": "space",
"38": "keyup",
"40": "keydown",
"48": "0",
"49": "1",
"50": "2",
"51": "3",
"52": "4",
"53": "5",
"54": "6",
"55": "7",
"56": "8",
"57": "9",
"134": "F23",
"135": "F24"
}
Usage example
Digamos que você queira fazer alguma ação na tela com base em alguma chave POS.
<svelte:window on:keyup="onKeyup(event)" />
<script>
import Keyboard from '@mamba/keyboard/api/index.js';
import { KEYBOARD } from '@mamba/core';
export default {
methods: {
onKeyup(event) {
const { keyCode } = event;
const { KEY_NAMES, KEY_CODES } = KEYBOARD;
const keyName = Keyboard.getKeyName(keyCode);
if (keyName === KEY_NAMES.BACK) {
} else if (keyName === KEY_NAMES.ENTER) {
}
if (keyCode === KEY_CODES.SHORTCUTS) {
}
},
},
};
</script>